# -*- coding: utf-8 -*-
# @Author: lidongdong
# @time  : 19-6-19 下午6:52
# @file  : attention_weight.py

"""
usage:
"""

import numpy as np
import matplotlib.pyplot as plt


def main():
    figure = plt.figure(figsize=(11, 10))
    x_ticks = ["Q", "bird", "head", "legs", "slides", "wood"]
    y_ticks = ["wood /r/DistinctFrom carpet", "word /r/AtLocation a fire", "split /r/DistinctFrom like"]
    plt.xticks(range(len(x_ticks)), x_ticks)
    plt.yticks(range(len(y_ticks)), y_ticks)
    plt.plot(np.arange(10), np.arange(10), alpha=1)
    # plt.text()
    ax = plt.gca()

    # p = plt.Rectangle((0.1, 0.1), 0.9, 0.9, fill=False)
    # p.set_transform(ax.transAxes)
    # p.set_clip_on(False)
    # ax.add_patch(p)

    plt.axis("off")
    left = 0.1
    top = 0.9
    ax.text(left, top, 'rotated\nwith newlines',
            horizontalalignment='center',
            verticalalignment='center',
            rotation=90,
            transform=ax.transAxes,
            fontsize=20)

    ax.text(0.15, 0.07, "Q",
            horizontalalignment='center',
            verticalalignment='bottom',
            rotation=90,
            transform=ax.transAxes,
            fontsize=20)

    ax.text(0.25, 0.00, "QQQQ",
            horizontalalignment='center',
            verticalalignment='bottom',
            rotation=90,
            transform=ax.transAxes,
            fontsize=20)

    ax.text(0.35, 0.0, "QQQQ",
            horizontalalignment='center',
            verticalalignment='bottom',
            rotation=90,
            transform=ax.transAxes,
            fontsize=20)

    ax.text(0.0, 0.15, "QQQQ",
            horizontalalignment='left',
            verticalalignment='center',
            transform=ax.transAxes,
            fontsize=20)
    #
    x = np.linspace(1 - 0.5, 2 - 0.5, 1000)
    y1 = np.linspace(2 - 0.5, 2 - 0.5 , 1000)
    y2 = np.linspace(1 - 0.5, 1 - 0.5, 1000)
    plt.fill_between(x, y1, y2, where=y1>y2, facecolor="green")

    x = np.linspace(2 - 0.5, 3 - 0.5, 1000)
    y1 = np.linspace(3 - 0.5, 3 - 0.5 , 1000)
    y2 = np.linspace(2 - 0.5, 2 - 0.5, 1000)
    plt.fill_between(x, y1, y2, where=y1>y2, facecolor="green", alpha=.5)
    plt.show()


if __name__ == '__main__':
    main()
